/*
	Author: Sebastian Mountaniol, mountaniol@gmail.com
	Initialization of updater's structures.
*/

#include "string.h"
#include "updater.types.h"
#include "updater.w.h"
#include "updater.errors.h"
#include "updater.w.memory.h"
#include "updater.w.system.h"
#include "updater.w.string.h"
#include "updater.h"


INT init_ucore(ucore_t * ps_u)
{
    CHAR * pc_env;
    INT i_env;
    if(NULL == ps_u)
    {
        RETURN(-EARGUMENT);
    }

    memset(ps_u, 0, sizeof(ucore_t));

    ps_u->env.major = MAJOR;
    ps_u->env.minor = MINOR;

    pc_env = w_get_pwd();
    if (NULL != pc_env)
    {
        i_env = w_strlen(pc_env);
        ps_u->env.root = w_malloc(i_env + 1);
        w_strncpy(ps_u->env.root, pc_env, i_env);
        w_printf("Root is: %s\n", ps_u->env.root);
    }
    else
    {
        ps_u->env.root = NULL;
    }

    w_free(pc_env);

    RETURN(OK);
}
